package com.vincent.kdp.js;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

import com.vincent.kdp.Activity.QualitypolicyActivity;
import com.vincent.kdp.ui.commodity.repository.CommodityDetailRepository;
import com.vincent.kdp.util.BaseParam;

/**
 * Created by Administrator on 2017/5/23 0023.
 */

public class ShopCartOperator {
    private Activity activity;
    private String ids;
   // private CommodityDetailRepository repository=new CommodityDetailRepository();

    public ShopCartOperator(Activity activity,String ids) {
        this.activity = activity;
        this.ids=ids;
        Log.i("code",ids+"-ids---");
    }
    @JavascriptInterface
    public String getDeviceId(){
        return BaseParam.getDeviceId();
    }
    @JavascriptInterface
    public String shoppingIds(){
        return ids;
    }
    @JavascriptInterface
    public String getBarCode(){
        return "44444";
    }
    @JavascriptInterface
    public String getName(){
        return "4444";
    }
    @JavascriptInterface
    public String getPrice() {
        return "4444";
    }


    @JavascriptInterface
    public void getWebId(final String message,final String url){
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Log.i("code",message);
                if("请求成功".equals(message)){
                    Toast.makeText(activity, url, Toast.LENGTH_SHORT).show();
                    //MainActivity.reload=1;
                    Intent intent =new Intent(activity, QualitypolicyActivity.class);
//                    intent.putExtra("barCode", barCode);
                    intent.putExtra("url", url);
                    activity.startActivity(intent);

                }
            }
        });

    }
}
